<template>
  <div>
    <div style="overflow: auto; height: 500px">
      <el-table
        :data="recordsList"
        style="width: 100%"
        empty-text="暂无申请记录"
      >
        <el-table-column type="index" label="记录" width="100px">
        </el-table-column>
        <el-table-column prop="handlestatus" label="处理状态" width="300px">
          <template slot-scope="scope">
            {{ scope.row.handlestatus ? "已处理" : "未处理" }}
          </template>
        </el-table-column>
        <el-table-column prop="handleresult" label="处理结果" width="300px">
          <template slot-scope="scope">
            <div v-if="!scope.row.handlestatus">未处理</div>
            <div v-else>
              {{ scope.row.handleresult ? "通过" : "未通过" }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="uploadtime" label="提交时间" width="300px">
          <template slot-scope="scope">
            {{ formatDate(scope.row.uploadtime) }}
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
export default {
  created() {
    this.getApplyListByUserId();
  },
  data() {
    return {
      recordsList: [],
    };
  },
  methods: {
    //获取用户申请列表
    getApplyListByUserId() {
      this.$request.getHttp({
        url: "/consultapply/getApplyListByUserId",
        params: {
          userId: localStorage.getItem("userId"),
        },
        success: (data) => {
          if (data.code == 200) {
            this.recordsList = data.list;
          }
        },
        error: (error) => {},
      });
    },
    //格式化日期
    formatDate(originalDate) {
      // 创建 Date 对象
      const date = new Date(originalDate);

      // 使用 Date 对象的方法获取年、月、日、小时、分钟和秒
      const year = date.getFullYear();
      const month = ("0" + (date.getMonth() + 1)).slice(-2);
      const day = ("0" + date.getDate()).slice(-2);
      const hours = ("0" + date.getHours()).slice(-2);
      const minutes = ("0" + date.getMinutes()).slice(-2);
      const seconds = ("0" + date.getSeconds()).slice(-2);

      // 将获取到的年月日时分秒拼接成指定格式的字符串
      const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;

      return formattedDate;
    },
  },
};
</script>

<style>
</style>